Repository navigation
Add gradient alpha interpolation option and Fill(Pen) - #436
Merged
Merged
Conversation
- Update SixLabors.ImageSharp to 5.0.0-alpha.0.38 and fix the API breaks. - Add AlphaRepresentation to GradientBrush and PathGradientBrush. Associated (the default) interpolates premultiplied colors, as CSS Color 4 requires. All other values interpolate unassociated colors, as SVG 2 requires. Both the CPU and the WebGPU backends obey it. - Use the ImageSharp 5 pixel alpha APIs in the gradient encoders, the WebGPU ramp and solid color specialization, and the acrylic tint. - Add DrawingCanvas.Fill(Pen, ...). It fills the stroke of the path with the brush of the pen and the non-zero rule. The drawing transform changes the stroke as it changes all filled shapes. - Update the tests for ImageSharp 5: 15 default formats, and HalfSingle values in the HDR range.
The CPU acrylic, drop shadow, backdrop drop shadow, glow and inner shadow effects converted the tint color to Rgba32 before they built the color matrix. That cut the tint to 8 bits for each channel, while the WebGPU effects use the full-precision color. The CPU effects now use Color.ToScaledVector4 with the same alpha representation as their WebGPU counterparts.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #436 +/- ##
=====================================
Coverage 80% 80%
=====================================
Files 439 439
Lines 49890 49960 +70
Branches 5892 5891 -1
=====================================
+ Hits 40297 40390 +93
+ Misses 7998 7972 -26
- Partials 1595 1598 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Description
Gradient alpha interpolation
GradientBrush(linear, radial, elliptic, sweep) andPathGradientBrushget a newPixelAlphaRepresentation AlphaRepresentationproperty and new constructor overloads.Associatedis the default. It interpolates premultiplied colors, as CSS Color 4 requires. The existing output does not change.Transform,EqualsandGetHashCodeinclude it.DrawingCanvas.Fill(Pen, ...)Fill(Pen, IPath), withRectangle,IPathCollectionandPathBuilderoverloads.Pen.GeneratePathreturns with the brush of the pen. The stroke always uses the non-zero fill rule.Draw(Pen, ...)keeps an even stroke width.ImageSharp 5
HalfSinglepath gradient test uses values in the [0, 1] range, because ImageSharp 5 keepsHalfSinglevalues as HDR values.Layer effect tint
Rgba32before they built the color matrix. That cut the tint to 8 bits for each channel.Tests
Transformkeeps the alpha representation.Fill(Pen, ...)under a non-uniform scale.Fill(Pen, ...)uses the non-zero rule under an even-odd state.